package ctrFinanceiro.gui.grid;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import ctrFinanceiro.dmp.Conta;

public class TableModelConta extends AbstractTableModel{
    
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private List<Conta> contas;
    

    public TableModelConta(List<Conta> conta) {
        
        this.contas = conta;
    }
    
    public Object getValueAt(int rowIndex, int columnIndex){
        
        Conta conta = contas.get(rowIndex);
        
        switch(columnIndex){            
            case 0: return conta.getIdCta();
            case 1: return conta.getDescricao();
            case 2: return conta.getCategoria().getDescricao();
            case 3: return conta.getCategoria().getTipo();
        }
        return null;       
    }
    
    public int getRowCount(){
    	if (null == contas) {
    		return 0;
    	} else {
    		return contas.size();
    	}
    }
    
    public int getColumnCount(){
        return 4;
    }
    
    public Conta getValues(int rowIndex){
        return contas.get(rowIndex);
    }
}
